import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router'
import { GuardEach } from './permission'

// 静态 路由
const routes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'Login',
    component: async () => await import('@/views/login/index.vue')
  },
  {
    path: '/', // 主页
    name: 'Dashboard',
    component: async () => await import('@/layout/index.vue'),
    redirect: '/dashboard/analysis',
    children: [] //  动态路由 等待请求接口，给children赋值
  },
  {
    path: '/:pathMatch(.*)*', // 404
    component: async () => await import('@/views/NotFound/index.vue')
  }
]

const router = createRouter({
  routes,
  history: createWebHashHistory()
})
GuardEach(router)

export default router
